package com.sun.stringescapeutils;



import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegularExceptionTest0 {
    public static  void main(String[] args) throws IOException {
        File file = new File("F:/AnHeng/Nessus-20210331105831_5eyxtd.html");
        Document parse = Jsoup.parse(file, "utf-8","");
        Elements elements = parse.select("div[style=\"box-sizing: border-box; width: 100%; background: #eee; font-family: monospace; padding: 20px; margin: 5px 0 20px 0;\"]");
        Element element = elements.get(0);
        String str = element.text();
        System.out.println(str);

        Matcher matcher1 = Pattern.compile("C=GB/ST=\\W*").matcher(str);
        if (matcher1.find()){
            System.out.println(matcher1.start()+" "+matcher1.end());
            System.out.println(str.substring(matcher1.start()+8,matcher1.end()-1));
        }

        Matcher matcher2 = Pattern.compile("L=\\W*").matcher(str);
        if (matcher2.find()){
            System.out.println(matcher2.start()+" "+matcher2.end());
            System.out.println(str.substring(matcher2.start()+2,matcher2.end()-1));
        }
        Matcher matcher3 = Pattern.compile("O=\\W*").matcher(str);
        if (matcher3.find()){
            System.out.println(matcher3.start()+" "+matcher3.end());
            System.out.println(str.substring(matcher3.start()+2,matcher3.end()-1));
        }

//        Pattern compile = Pattern.compile("C=GB/ST=\\W*/L=\\W*/O=\\W*/OU=\\W*/CN=\\W*\\S$");
//        Matcher matcher = compile.matcher(str);
//        while (matcher.find()){
//            System.out.println(matcher.start()+" "+matcher.end());
//            String subStr = str.substring(matcher.start(),matcher.end());
//            System.out.println(str.substring(matcher.start(),matcher.end()));
//        }
    }


}
